package com.wyc.serviceMap.controller;

import com.wyc.internalCommon.response.TerminalResponse;
import com.wyc.internalCommon.response.TrSearchResponse;
import com.wyc.internalCommon.result.ApiResult;
import com.wyc.serviceMap.service.TerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 终端controller
 */
@RequestMapping("/terminal")
@RestController
public class TerminalController {

    @Autowired
    private TerminalService terminalService;

    /**
     * 添加终端
     * @param name
     * @return
     */
    @RequestMapping("/add")
    public ApiResult<TerminalResponse> addTerminal(@RequestParam("name") String name,@RequestParam("carId") String carId){
        return terminalService.add(name,carId);
    }


    /**
     * 搜索周边终端
     * @param center
     * @param radius
     * @return
     */
    @RequestMapping("/aroundSearch")
    public ApiResult<List<TerminalResponse>> aroundSearch(@RequestParam("center") String center,@RequestParam("radius") Integer radius){
        return terminalService.aroundSearch(center,radius);
    }

    /**
     * 查询轨迹信息
     * @param tid
     * @param starttime
     * @param endtime
     * @return
     */
    @RequestMapping("/trsearch")
    public ApiResult<TrSearchResponse> trsearch(@RequestParam("tid") String tid, @RequestParam("starttime") Long starttime, @RequestParam("endtime") Long endtime){
        return terminalService.trsearch(tid,starttime,endtime);
    }

}
